package com.mingqijia.gassafety.shared.constant;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import io.swagger.models.auth.In;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;


@Getter
@RequiredArgsConstructor
public enum PushTypeEnum {

    //1本地消息中心 2 短信推送 3 微信模版消息 4机器人外呼
    PUSH_ALL(0, "所有方式", new Integer[]{1, 2, 3, 4}),
    PUSH_LOCAL(1, "本地消息推送", new Integer[]{1}),
    PUSH_SMS(2, "短信推送", new Integer[]{2}),
    PUSH_WECHAT(3, "微信推送", new Integer[]{3}),
    PUSH_SMS_LOCAL(4, "本地消息+短信推送", new Integer[]{1, 2}),
    PUSH_WECHAT_LOCAL(5, "本地消息+微信", new Integer[]{1, 3}),
    PUSH_WECHAT_SMS(6, "短信+微信", new Integer[]{2, 3}),
    PUSH_CALL(7, "外呼", new Integer[]{4}),
    PUSH_CALL_LOCAL(8, "本地消息+外呼", new Integer[]{1, 4}),
    PUSH_CALL_WECHAT(9, "微信+外呼", new Integer[]{3, 4}),
    PUSH_CALL_SMS(10, "短信+外呼", new Integer[]{2, 4}),
    PUSH_CALL_SMS_LOCAL(11, "本地消息+短信+外呼", new Integer[]{1, 2, 4}),
    PUSH_CALL_WECHAT_LOCAL(12, "本地消息+微信+外呼", new Integer[]{1, 3, 4}),
    PUSH_CALL_SMS_WECHAT(13, "短信+微信+外呼", new Integer[]{2, 3, 4}),
    PUSH_WECHAT_LOCAL_SMS(14, "本地消息+短信+微信", new Integer[]{1, 2, 3});

    private final int code;
    private final String name;
    private final Integer[] types;


    public static  Set<Integer> getPushTypes(List<Integer> types,int t) {
        Set<Integer> result = new HashSet<>();
        if (CollectionUtil.isEmpty(types)){
            types =new ArrayList<>();
            types.add(t);
        }
        for (Integer type : types) {
            List<Integer> r = Arrays.stream(PushTypeEnum.values()).filter(pushTypeEnum -> {
                return Arrays.asList(pushTypeEnum.getTypes()).contains(type);
            }).map(PushTypeEnum::getCode).collect(Collectors.toList());
            result.addAll(r);
        }
        return result;
    }

    public static void main(String[] args) {
//        Set<Integer> types = PushTypeEnum.getPushTypes(null, 4);
//        System.out.println(types);
//        int i = DateUtil.dayOfMonth();
//        LocalDate now = LocalDate.now();
//        System.out.println(now);
//        int i = LocalDate.now().lengthOfMonth();
//        System.out.println(i);
        DateTime parse = DateUtil.parse("2024-03-31");
        DateTime dateTime = DateUtil.offsetMonth(parse,-1);
        System.out.println(dateTime);
        System.out.println(dateTime.dayOfMonth());
//        String format = DateUtil.format(date, "yyyy-MM-dd")+" 08:00";
//        DateTime parse = DateUtil.parse(format);
//        System.out.println(format);
//        System.out.println(parse);
//        System.out.println(DateUtil.offsetDay(date, 1));
    }
}
